<?php
    $permissoes = $_SESSION['permissoes'];
    $menus = $_SESSION['menus'];
    
    if(!preg_match('@' . implode('|', $permissoes) . '@', $this->uri->uri_string())){
        redirect('admin/home/sem_permissao');
    }
    
    function isStackeholderOnly(){
        return  in_array('Stakeholders', $_SESSION['perfis'])&& count($_SESSION['perfis']) == 1;
    }
    
    function isTestador(){
        return in_array('Testador', $_SESSION['perfis']);
    }
    
    function isAnalista(){
        return in_array('Analista', $_SESSION['perfis']);
    }
    
    function isAdmin(){
        return in_array('Administrador', $_SESSION['perfis']);
    }
    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GERENCIA PROJETOS</title>
    <meta name="keywords" content="projeto, teste, desenvolvimento, php, codeigniter, doctrine" />
    <meta name="description" content="gerenciaprojeto.esy.es" />

    <link rel="stylesheet" type="text/css" href="<?php echo base_url('assets/js/jquery/jquery-ui-1.10.3.custom/development-bundle/themes/smoothness/jquery-ui.css'); ?>" />
    <script type="text/javascript" src="<?php echo base_url('assets/js/jquery/jquery.js'); ?>"></script>
    <script type="text/javascript" src="<?php echo base_url('assets/js/jquery/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.js'); ?>"></script>

    <link href="<?php echo base_url('assets/css/template_style.css'); ?>" rel="stylesheet" type="text/css" />
    <link href="<?php echo base_url('assets/css/menu/style.css'); ?>" rel="stylesheet" type="text/css" />
    <link href="<?php echo base_url('assets/css/menu/menu1.css'); ?>" rel="stylesheet" type="text/css" />
    <script src="<?php echo base_url('assets/js/jquery/jquery-slidedeck/jquery-slidedeck.pack.lite.js'); ?>" type="text/javascript"></script>
    <script src="<?php echo base_url('assets/js/jquery/datetimepicker/datetimepicker.js'); ?>"></script>
    <script src="<?php echo base_url('assets/js/funcoes.js'); ?>" type="text/javascript"></script>
</head>
<body>

<div id="template_body_wrapper">
    <div id="template_wrapper">
        <div id="template_header">
            <div id="site_title">
                <h1><a href="#"></a></h1></div>
            <div class="cleaner"></div>
        </div> <!-- END of template_header -->
        <div id="template_menubar">
            <div class="codropsmenu1" id="menu">
                <ul>
                    <li><a href="<?php echo site_url('admin/home/index');?>" class="first"><span>Início</span></a></li>
                    <?php if (in_array('suiteteste' ,$menus)){?>
                        <li><a href="<?php echo site_url('admin/suiteteste/index');?>"><span>Suítes</span></a></li>
                    <?php }?>
                    <?php if (in_array('projeto', $menus)){?>
                        <li><a href="<?php echo site_url('admin/projeto/index');?>"><span>Projetos</span></a></li>
                    <?php }?>
                    <?php if (in_array('casoteste' ,$menus)){?>
                        <li><a href="<?php echo site_url('admin/casoteste/index');?>"><span>Casos de Testes</span></a></li>
                    <?php }?>
                    <?php if (in_array('logteste' ,$menus)){?>
                        <li><a href="<?php echo site_url('admin/logteste/index');?>"><span>Logs</span></a></li>
                    <?php }?>
                    <?php if (in_array('scriptteste' ,$menus)){?>
                        <li><a href="<?php echo site_url('admin/scriptteste/index');?>"><span>Scripts</span></a></li>
                    <?php }?>
                    <li><a href="<?php echo site_url('admin/relatorio/index');?>"><span>Relatórios</span></a></li>
                    <?php if (in_array('usuario' ,$menus)){?>
                        <li><a href="<?php echo site_url('admin/usuario/index');?>"><span>Usuários</span></a></li>
                    <?php }?>
                    <li><a href="<?php echo site_url('admin/login/do_logout');?>" class="last"><span>Sair</span></a></li>
                </ul>
            </div>
            <div style="height: 25px; padding-left: 20px; line-height: 25px; border-bottom: 1px #ccc dotted; z-index: 999; margin: 0 auto; width: 940px;">
                <?php 
                $login = $_SESSION['usuario']->get_login();
                $perfil = $_SESSION['perfis']['desc_perfil'];
                printf("<b>Usuário:</b> $login - <b>Perfil:</b> $perfil");?>
                
            </div>
        </div>
        <div id="template_main">
            <div class="cleaner corpo">
<?php
                // o arquivo de template a ser incluido foi informado?
                if(!empty($_template)) {
                    // procuramos ele a partir deste arquivo
                    $_template = dirname(__FILE__) . '/' . $_template;
                    // se existir, fazemos o include
                    if(file_exists($_template)){
                        include $_template;
                    // se nao existir, enviamos uma mensagem
                    } else {
                        echo 'Template "', $_template, '" não existe!';
                    }
                // se nao informou, enviamos uma mensagem
                } else {
                    echo 'Template nao informado!';
                }
?>
            </div>
        </div> <!-- END of template_main -->
        <div id="template_footer">

        </div> <!-- END of template_footer -->
    </div> <!-- END of template_wrapper -->
</div> <!-- END of template_body_wrapper -->

</body>
</html>